import request from '@/config/axios'

/** CRM_业绩配置信息 */
export interface PerformanceConfig {
  id: number;
  year: number; // 所属年份
  deptId: number; // 部门id 关联system_dept.id
  deptIdS: [];
  performancePoint: string; // 指标点
  targetValue1: string; // 1月份目标值
  targetValue2: string; // 2月份目标值
  targetValue3: string; // 3月份目标值
  targetValue4: string; // 4月份目标值
  targetValue5: string; // 5月份目标值
  targetValue6: string; // 6月份目标值
  targetValue7: string; // 7月份目标值
  targetValue8: string; // 8月份目标值
  targetValue9: string; // 9月份目标值
  targetValue10: string; // 10月份目标值
  targetValue11: string; // 11月份目标值
  targetValue12: string; // 12月份目标值
}
/** CRM_业绩结果 **/
export interface PerformanceResult  {
  id: number;
  year: number; // 所属年份
  month: number;
  deptId: number; // 部门id 关联system_dept.id
  performancePoint: string; // 指标点
  targetValue: string; // 目标值
  finishValue: string; // 完成值
  finishRate: string; // 达成率
}
// CRM_业绩配置 API
export const PerformanceConfigApi = {
  // 查询CRM_业绩配置分页
  getPerformanceConfigPage: async (params: any) => {
    return await request.get({ url: `/crm/performance/config/page`, params })
  },

  // 查询CRM_业绩配置详情
  getPerformanceConfig: async (id: number) => {
    return await request.get({ url: `/crm/performance/config/get?id=` + id })
  },

  // 新增CRM_业绩配置
  createPerformanceConfig: async (data: PerformanceConfig) => {
    return await request.post({ url: `/crm/performance/config/create`, data })
  },

  // 修改CRM_业绩配置
  updatePerformanceConfig: async (data: PerformanceConfig) => {
    return await request.put({ url: `/crm/performance/config/update`, data })
  },

  // 删除CRM_业绩配置
  deletePerformanceConfig: async (id: number) => {
    return await request.delete({ url: `/crm/performance/config/delete?id=` + id })
  },

  /** 批量删除CRM_业绩配置 */
  deletePerformanceConfigList: async (ids: number[]) => {
    return await request.delete({ url: `/crm/performance/config/delete-list?ids=${ids.join(',')}` })
  },

  // 导出CRM_业绩配置 Excel
  exportPerformanceConfig: async (params) => {
    return await request.download({ url: `/crm/performance/config/export-excel`, params })
  },
  // 查询业绩结果分页
  getPerformanceResultPage: async (params: any) => {
    return await request.get({ url: `/crm/performance/config/result/page`, params })
  }
}
